import 'package:flutter/cupertino.dart';
import 'package:ball_lion/resources/colours.dart';
import 'package:ball_lion/utils/utils.dart';

import 'package:ball_lion/widgets/base/wqs_text.dart';

class ExpertRecordTag extends StatelessWidget {
  const ExpertRecordTag(
      {super.key,
      required this.type,
      required this.text,
      this.textSize,
      this.fontWeight,
      this.radius})
      : tagType = null;
  const ExpertRecordTag.custom(
      {super.key,
      this.text,
      this.textSize,
      this.fontWeight,
      this.tagType,
      this.radius})
      : type = null;

  final String? text;
  final double? textSize;
  final FontWeight? fontWeight;
  final int? type;
  final TagType? tagType;
  final double? radius;

  @override
  Widget build(BuildContext context) {
    TagType tag = TagType.common;
    switch (type) {
      case 1:
        tag = TagType.first;
        break;
      case 2:
        tag = TagType.second;
        break;
      case 3:
        tag = TagType.third;
        break;
      case 4:
        tag = TagType.common;
        break;
      case 5:
        tag = TagType.league;
        break;
      case 6:
        tag = TagType.text;
        break;
    }
    if (tagType != null) {
      tag = tagType!;
    }
    return text.noValue
        ? Container()
        : Container(
            padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(radius ?? 4),
                gradient: tag.gradientColor.hasValue
                    ? LinearGradient(colors: tag.gradientColor!)
                    : null,
                border: tag.borderColor != null
                    ? Border.fromBorderSide(
                        BorderSide(width: 0.5, color: tag.borderColor!),
                      )
                    : null,
                color: tag.backgroundColor),
            child: QsText(text!,
                textAlign: TextAlign.center,
                needCenter: true,
                textWidthBasis: TextWidthBasis.longestLine,
                maxLines: 2,
                fontWeight: fontWeight,
                fontSize: textSize ?? 10,
                color: tag.textColor),
          );
  }
}

class TagType {
  static TagType first = TagType(
      textColor: Colours.white,
      gradientColor: const [Color(0xFFFDDD74), Color(0xFFFEC230)]);

  static TagType second = TagType(
      textColor: Colours.white,
      gradientColor: const [Color(0xFFBAE1E9), Color(0xFFA4CCD3)]);

  static TagType third = TagType(
      textColor: Colours.white,
      gradientColor: const [Color(0xFFEBB25A), Color(0xFFBB8026)]);

  static TagType common = TagType(
      textColor: Colours.main,
      borderColor: Colours.main,
      backgroundColor: Colours.redFFF2F2);

  static TagType league = TagType(
      textColor: Colours.orangeFF8730,
      borderColor: Colours.orangeFF8730,
      backgroundColor: Colours.transparent);

  static TagType text = TagType(textColor: Colours.main);

  Color? textColor;
  Color? borderColor;
  List<Color>? gradientColor;
  Color? backgroundColor;

  TagType(
      {this.textColor,
      this.backgroundColor,
      this.gradientColor,
      this.borderColor});
}
